#!/usr/bin/env python3
#-*-coding: utf-8-*-

# Version: 0.1
# Author: Don Li <don.li@mai.tipcat.com>
# License: Copyright(c) 2015 Don.Li
# Summary:

import os
import sys
import zipfile

PRJ       = 'server'
DEST_PATH = './psvr'


def zipProject():
    global PRJ

    zfile = zipfile.PyZipFile(
            '{0}/{1}.psvr'.format(DEST_PATH, PRJ),
            mode='w',
            compression=zipfile.ZIP_DEFLATED
    )

    PRJ = 'src/' + PRJ

    zfile.writepy(PRJ, '')

    for path in os.listdir(PRJ):
        full_path = os.path.join(PRJ, path)
        if os.path.isdir(full_path):
            zfile.writepy(full_path)

    zfile.close()

def main():
    global PRJ, DEST_PATH

    if len(sys.argv) > 1:
        PRJ = sys.argv[1].strip()

    if len(sys.argv) > 2:
        DEST_PATH = sys.argv[2].strip()

    zipProject()

if __name__ == "__main__": main()
